package com.project.service.Impl;

import java.math.BigInteger;
import java.util.List;

import javax.jws.soap.SOAPBinding.Use;

import com.project.dao.UserDao;
import com.project.service.UserService;
import com.project.util.StringUtil;
import com.project.vo.Admin;
import com.project.vo.User;
import com.project.vo.Validator;

public class UserServiceImpl implements UserService {

	private UserDao userDao;
	public UserDao getUserDao() {
		return userDao;
	}
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}
	@Override
	public User login(Integer userId, String password) {
		// TODO Auto-generated method stub
		User result = userDao.login(userId, password);
		return result;
	}

	@Override
	public String findPassword(Integer userId, String password) {
		// TODO Auto-generated method stub
		String result = userDao.updatePassword(userId, password);
		return result;
	}
	
	@Override
	public String register(User user) {
		String result = userDao.register(user);
		return result;
	}
	
	@Override
	public String update(Integer userId, User user) {
		// TODO Auto-generated method stub
		String result = userDao.update(userId, user);
		return result;
	}
	@Override
	public User view(Integer userId) {
		// TODO Auto-generated method stub
		User result = userDao.view(userId);
		return result;
	}
	@Override
	public String saveCode(String email, String code) {
		// TODO Auto-generated method stub
		//判断email是否存在
		User isEmailExist = userDao.findUserByEmail(email);
		if (isEmailExist != null) {
			return userDao.saveCode(email, code);
		}
		return StringUtil.FAILURE;
	}
	@Override
	public String getCode(String email) {
		// TODO Auto-generated method stub
		Validator validator = userDao.findValidatorByEmail(email);
		return validator.getCode();
	}
	@Override
	public List<User> getAllUser(Integer pageNum, Integer pageSize) {
		// TODO Auto-generated method stub
		return userDao.getAllUser(pageNum, pageSize);
	}
	@Override
	public List<User> getAllUser() {
		// TODO Auto-generated method stub
		return userDao.getAllUser();
	}
	@Override
	public Admin login_A(Integer id, String password) {
		// TODO Auto-generated method stub
		return userDao.login_A(id, password);
	}
	@Override
	public Admin view_A(Integer id) {
		// TODO Auto-generated method stub
		return userDao.view_A(id);
	}
	@Override
	public String delete(Integer id) {
		// TODO Auto-generated method stub
		return userDao.delete(id);
	}

}
